<%@ Page Language="VB" ValidateRequest="false" Strict="false" MasterPageFile="~/Default.master" Title="Untitled Page" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>



<script runat="server">
#Region "Diclaimer"
'Copyright (c) 2006, Mark Bracewell (bracewell at wgg dot com)
'All rights reserved.
'Redistribution and use in source and binary forms, with or without
'modification, are permitted provided that the following conditions are met: 
'*

'* Redistributions of source code must retain the above copyright
'notice, this list of conditions and the following disclaimer.
'* Redistributions in binary form must reproduce the above copyright
'notice, this list of conditions and the following disclaimer in the
'documentation and/or other materials provided with the distribution.
'* The name Mark Bracewell may not be used to endorse or promote products
'derived from this software without specific prior written permission. 
'* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY
'EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
'WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
'DISCLAIMED. IN NO EVENT SHALL MARK BRACEWELL BE LIABLE FOR ANY
'DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
'(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
'LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
'ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
'(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
'SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
#End Region    
    Private IsSelf As Boolean
    Private CanEdit As Boolean
    
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If User.Identity.IsAuthenticated Then
            Try
                Dim uGuid As Guid = New Guid(Request("id"))
                IsSelf = Membership.GetUser.ProviderUserKey.ToString.Equals(uGuid.ToString())
                CanEdit = IsSelf
            Catch ex As Exception
                Response.Redirect("topics.aspx")
            End Try
        Else
            IsSelf = False
            CanEdit = False
        End If
        If Not IsPostBack Then
            CType(FormView1.FindControl("EditButton"), Control).Visible = CanEdit
        End If
    End Sub
    
    Protected Sub FormView1_ModeChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewModeEventArgs)
        If Not CanEdit Then
            e.Cancel = True
            Return
        End If
    End Sub
    
    Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim fview As FormView = CType(sender, FormView)
    End Sub
    
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="body">
        <div class="fullwidth">
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetForumUser" TypeName="ClubStarterKit.Data.Member" DataObjectTypeName="ClubStarterKit.Data.Member">
                <SelectParameters>
                    <asp:QueryStringParameter Name="memberid" QueryStringField="id" Type="Object" />
                </SelectParameters>
            </asp:ObjectDataSource>
            &nbsp;&nbsp;
            <asp:FormView OnDataBound="FormView1_DataBound" Width="100%" ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" OnModeChanging="FormView1_ModeChanging">
                <ItemTemplate>
                    <asp:Image AlternateText='<%# Bind("DisplayName") %>' BorderColor="#808080" BorderStyle="Solid"
                        BorderWidth="1" ImageAlign="Right" ID="AvatarImage" runat="server" ImageUrl='<%# "~\UserControls\AvatarImagefetch.ashx?Memberid=" + Eval("MemberId").ToString() %>' />
                    <h2>
                        <asp:Label ID="DisplayNameLabel" runat="server" Text='<%# Bind("DisplayName") %>'>
                        </asp:Label>
                        <asp:Image ID="OnlineImg" runat="server" Skinid="online" ToolTip="Online" AlternateText="Online"
                            Visible='<%# Bind("Online") %>'></asp:Image></h2>
                    <table width="80%">
                        <tr>
                            <td align="right" valign="top">
                                Email:
                            </td>
                            <td valign="top">
                                <asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email") %>' Visible='<%# Eval("ShowEmail") %>'></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" valign="top">
                                Bio:
                            </td>
                            <td valign="top" width="80%">
                                <asp:Label ID="BioLabel" runat="server" Text='<%# Bind("Bio") %>'></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" valign="top">
                                Joined:
                            </td>
                            <td valign="top">
                                <asp:Label ID="JoinedLabel" runat="server" Text='<%# Bind("Joined") %>'></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" valign="top">
                                LastLoginDate:
                            </td>
                            <td valign="top">
                                <asp:Label ID="LastLoginDateLabel" runat="server" Text='<%# Bind("LastLoginDate") %>'>
                                </asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" valign="top">
                                LastPostDate:
                            </td>
                            <td valign="top">
                                <asp:Label ID="LastPostDateLabel" runat="server" Text='<%# Bind("LastPostDate") %>'>
                                </asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" valign="top">
                                Posts:
                            </td>
                            <td valign="top">
                                <asp:Label ID="PostsLabel" runat="server" Text='<%# Bind("Posts") %>'></asp:Label>
                            </td>
                        </tr>
                    </table>
                    <Club:RolloverLink ID="EditButton" runat="server" CausesValidation="False" NavigateURL="~/member/details.aspx" Text="Edit Profile" />
                </ItemTemplate>
            </asp:FormView>
        </div>
    </div>
</asp:Content>
